package com.springdemo.spring5.service;

import com.springdemo.spring5.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created with IntelliJ IDEA.
 * User: zjz
 * Date: 2022/03/04 14:22
 * Description:
 * Version: V1.0
 */
@Service
@Transactional(timeout = -1,propagation = Propagation.REQUIRED,isolation = Isolation.REPEATABLE_READ)
public class UserService {
    //注入dao
    @Autowired
    private UserDao userDao;

    //转账的方法
    public void AccountMoney(){
        //lucy少100
        userDao.reduceMoney();

        //模拟异常
        int i=10/0;

        //mery多100
        userDao.addMoney();
    }
}
